<?php
class db{
	public function getDBConn(){
        define("SERVERNAME","localhost");
        define("USERNAME","root");
        define("PASSWORD","root");
        define("DBNAME","crowdframedb");
//        define("DBNAME","crowdframetest");

        try{
            $db = new PDO('mysql:host='.SERVERNAME.';dbname='.DBNAME, USERNAME, PASSWORD);
			$db->query("SET NAMES gbk");
			return $db;
        } catch (PDOException $e) {
            die("Error: ".$e->getMessage());
        }
	}

	public function getMemcached(){
        $memcache = new Memcached();//创建一个memcached对象

        if(!$memcache->addServer('127.0.0.1', 11211)){
            die ("Could not connect");//连接Memcached服务器
        }
        return $memcache;
	}
}

?> 
